﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using IServices;
using GestionLinqLibData;
using UniversityManagerWebSite.Controllers;
using System.Web.Mvc;

namespace UnversityManager.Tests.Controllers
{
    /// <summary>
    /// Description résumée pour EleveControllerTest
    /// </summary>
    [TestClass]
    public class EleveControllerTest
    {
        private Mock<IEleveService> _service;

        [TestInitialize]
        public void Initialise()
        {
            _service = new Mock<IEleveService>();
        }

        [TestMethod]
        public void CreateValidContact()
        {
            //Arrange
            var _eleve = new eleve();
            _service.Setup(s => s.CreateEleve(_eleve)).Returns(true);
            var _controller = new EleveController(_service.Object);
            //Act
            var result = (RedirectToRouteResult)_controller.Create(_eleve);
            //Assert
            Assert.AreEqual("index", result.RouteValues["action"]);
        }

        [TestMethod]
        public void CreateInvalidContact()
        {
            //Arrange
            var _eleve = new eleve();
            _service.Setup(s => s.CreateEleve(_eleve)).Returns(false);
            var _controller = new EleveController(_service.Object);
            //Act
            var result = (ViewResult)_controller.Create(_eleve);
            //Assert
            Assert.AreEqual(String.Empty, result.ViewName);
        }
    }


}